package com.example.testapp;

import java.util.ArrayList;
import java.util.HashMap;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class CustomAdapter extends BaseAdapter{
	
	private Activity mActivity;
	private ArrayList<HashMap<String, String>> mArrayList;
	private static LayoutInflater mInflater = null;
//, ArrayList<HashMap<String, String>> list
	public CustomAdapter(Activity activity){
		mActivity = activity;
		//mArrayList = list;
		mInflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}
	
	@Override
	public int getCount() {
		return mArrayList.size();
	}

	@Override
	public Object getItem(int position) {
		return position;
	}

	@Override
	public long getItemId(int arg0) {
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup arg2) {
		View cView = convertView;
		
		if(cView == null){
			cView = mInflater.inflate(R.layout.list_row, null);
		}
		
		TextView sender = (TextView)cView.findViewById(R.id.sender);
		TextView content = (TextView)cView.findViewById(R.id.content);
		TextView timestamp = (TextView)cView.findViewById(R.id.timestamp);
		
		HashMap<String, String> message = new HashMap<String, String>();
		message = mArrayList.get(position);
		
		sender.setText("sender");
		content.setText("content");
		timestamp.setText("timestamp");
		
		return cView;
	}

}
